package com.astuetz.viewpager.extensions.example;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;

import com.astuetz.viewpager.extensions.FixedTabsView;
import com.astuetz.viewpager.extensions.IndicatorLineView;
import com.astuetz.viewpager.extensions.ScrollingTabsView;
import com.astuetz.viewpager.extensions.SwipeyTabsView;
import com.astuetz.viewpager.extensions.TabsAdapter;
import com.astuetz.viewpager.extensions.example.adapter.ExamplePagerAdapter;
import com.astuetz.viewpager.extensions.example.adapter.FixedIconTabsAdapter;
import com.astuetz.viewpager.extensions.example.adapter.FixedTabsAdapter;
import com.astuetz.viewpager.extensions.example.adapter.ScrollingTabsAdapter;
import com.astuetz.viewpager.extensions.example.adapter.SwipeyTabsAdapter;
import com.saudidentalapp.R;

public class PagerActivity extends Activity {
	
	private ViewPager mPager;
	private SwipeyTabsView mSwipeyTabs;
	private FixedTabsView mFixedTabs;
	private IndicatorLineView mLine;
	private ScrollingTabsView mScrollingTabs;
	
	private PagerAdapter mPagerAdapter;
	private TabsAdapter mSwipeyTabsAdapter;
	private TabsAdapter mFixedTabsAdapter;
	private TabsAdapter mScrollingTabsAdapter;
	
	public static final String EXTRA_EXAMPLE_TYPE = "EXTRA_EXAMPLE_TYPE";
	
	public enum ExampleType {
		SwipeyTabs, IndicatorLine, FixedTabs, FixedIconTabs, ScrollingTabs
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		
		ExampleType type = (ExampleType) getIntent().getSerializableExtra(EXTRA_EXAMPLE_TYPE);
		
		switch (type) {
		
			case SwipeyTabs:
				setContentView(R.layout.activity_swipey_tabs);
				initViewPager(10, 0xFFFFFFFF, 0xFF000000);
				mSwipeyTabs = (SwipeyTabsView) findViewById(R.id.swipey_tabs);
				mSwipeyTabsAdapter = new SwipeyTabsAdapter(this);
				mSwipeyTabs.setAdapter(mSwipeyTabsAdapter);
				mSwipeyTabs.setViewPager(mPager);
				break;
			
			case IndicatorLine:
				setContentView(R.layout.activity_line);
				initViewPager(5, 0xFF000000, 0xFFFFFFFF);
				mLine = (IndicatorLineView) findViewById(R.id.line);
				mLine.setViewPager(mPager);
				break;
			
			case FixedTabs:
				setContentView(R.layout.activity_fixed_tabs);
				initViewPager(3, 0xFFFFFFFF, 0xFF000000);
				mFixedTabs = (FixedTabsView) findViewById(R.id.fixed_tabs);
				mFixedTabsAdapter = new FixedTabsAdapter(this);
				mFixedTabs.setAdapter(mFixedTabsAdapter);
				mFixedTabs.setViewPager(mPager);
				break;
			
			case FixedIconTabs:
				setContentView(R.layout.activity_fixed_icon_tabs);
				initViewPager(3, 0xFFFFFFFF, 0xFF000000);
				mFixedTabs = (FixedTabsView) findViewById(R.id.fixed_icon_tabs);
				mFixedTabsAdapter = new FixedIconTabsAdapter(this);
				mFixedTabs.setAdapter(mFixedTabsAdapter);
				mFixedTabs.setViewPager(mPager);
				break;
			
			case ScrollingTabs:
				setContentView(R.layout.activity_scrolling_tabs);
				initViewPager(6, 0xFF000000, 0xFFFFFFFF);
				mScrollingTabs = (ScrollingTabsView) findViewById(R.id.scrolling_tabs);
				mScrollingTabsAdapter = new ScrollingTabsAdapter(this);
				mScrollingTabs.setAdapter(mScrollingTabsAdapter);
				mScrollingTabs.setViewPager(mPager);
				break;
		
		}
		
	}
	
	private void initViewPager(int pageCount, int backgroundColor, int textColor) {
		mPager = (ViewPager) findViewById(R.id.pager);
		mPagerAdapter = new ExamplePagerAdapter(this, pageCount, backgroundColor, textColor);
		mPager.setAdapter(mPagerAdapter);
		mPager.setCurrentItem(1);
		mPager.setPageMargin(1);
	}
	
}
